<?php

/*
 * Edit by xinli
 * Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
 */

namespace api\mall\controller;

use api\mall\model\CultureModel;
use cmf\controller\RestBaseController;

/**
 * @OA\Tag(
 *     name="mall-culture",
 *     description="文旅建筑"
 * )
 */
class CultureController extends RestBaseController
{
    protected function initialize()
    {
        parent::initialize();
        if (empty($this->user)) {
            $this->error('login');
        }
    }

    /**
     * 获取文旅建筑列表
     * @OA\Get(
     *     tags={"mall-culture"},
     *     path="/mall/culture/get_list",
     *     @OA\Parameter(name="page",in="query",description="页码",required=false,@OA\Schema(type="integer")),
     *     @OA\Parameter(name="size",in="query",description="每页数量",required=false,@OA\Schema(type="integer")),
     *     @OA\Response(response=200, ref="#/components/responses/200")
     * )
     */
    public function get_list()
    {
        $page = $this->request->param('page', 1, 'intval');
        $size = $this->request->param('size', 20, 'intval');
        $cultureModel = new CultureModel();
        $cultures = $cultureModel->page($page, $size)->select();

        foreach ($cultures as &$culture) {
            $culture['introduction_url'] = cmf_url('portal/Page/culture', array('id' => $culture['id']));
            $culture['video'] = cmf_get_image_url($culture['video']);
            unset($culture['introduction']);
        }
        $this->success('ok', $cultures);
    }
}
